package com.ericcson.innerportalapp;

import java.util.ArrayList;

import android.os.Bundle;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.view.Menu;

public class MainActivity extends Activity {
	
	public ArrayList<MainListItem> mainListItems = new ArrayList<MainListItem>(){/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	{
		add(new MainListItem("People", R.drawable.ic_action_group));
		add(new MainListItem("Announcements", R.drawable.ic_action_volume_on));
		add(new MainListItem("To-Do List", R.drawable.ic_action_view_as_list));
		add(new MainListItem("Emergency", R.drawable.ic_action_warning));
		add(new MainListItem("Office Locations", R.drawable.ic_action_place));
	}};
	
	public MainListArrayAdapter mainListArrayAdapter;
	MainListFragment mainListFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        FragmentManager fm = getFragmentManager();
        mainListFragment = (MainListFragment) fm.findFragmentById(R.id.main_list_container);
        if (mainListFragment == null) {
        	mainListFragment = new MainListFragment();
			
			FragmentTransaction ft = fm.beginTransaction();
			ft.add(R.id.main_list_container, mainListFragment);
			ft.commit();
		}
        
        mainListArrayAdapter = new MainListArrayAdapter(this, R.layout.main_list_item, mainListItems);
        mainListFragment.setListAdapter(mainListArrayAdapter);
        
    }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.main, menu);
//        return true;
//    }
    
}
